package com.cherry.ndkdemo;

import android.os.Bundle;
import android.os.Environment;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import org.fmod.FMOD;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author DongMS
 * @since 2020/4/28
 */
public class FmodActivity extends AppCompatActivity {

    private String mPath;
    private ExecutorService mThreadPool;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fmod);
        File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "1");
        mPath = new File(dir, "8.mp3").getAbsolutePath();
        mThreadPool = Executors.newCachedThreadPool();
    }

    public void normal(View view) {
        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                FmodUtils.fix(mPath, FmodUtils.MODE_NORMAL);
            }
        });

    }

    public void luoji(View view) {
        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                FmodUtils.fix(mPath, FmodUtils.MODE_LUOLI);
            }
        });

    }

    public void dashu(View view) {
        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                FmodUtils.fix(mPath, FmodUtils.MODE_DASHU);
            }
        });

    }

    public void jingsong(View view) {
        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                FmodUtils.fix(mPath, FmodUtils.MODE_JINGSONG);
            }
        });

    }

    public void gaoguai(View view) {
        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                FmodUtils.fix(mPath, FmodUtils.MODE_GAOGUAI);
            }
        });

    }

    public void kongling(View view) {
        mThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                FmodUtils.fix(mPath, FmodUtils.MODE_KONGLING);
            }
        });

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mThreadPool.shutdownNow();
        FMOD.close();
    }
}
